var removeDuplicates = function (nums) {
    if (nums.length === 0) return 0
    if (nums.length === 1) return 1
    let left = 0;
    let right = 1;
    let length = 1;
    while (right < nums.length) {
        if (nums[right] > nums[left]) {
            let num = right - left;
            length += num >= 2 ? 2 : num;
            left = right;
        }
        right += 1;
    }
    return length
};

removeDuplicates([1, 1, 1, 2, 2, 3])